package com.bawei.mvvm.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import com.bawei.mvvm.entity.BannerData
import com.bawei.mvvm.entity.Goods
import com.bawei.mvvm.http.ApiResponse
import com.bawei.mvvm.respository.MainRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(var mainRepository: MainRepository): ViewModel() {
    fun getBanners(): LiveData<ApiResponse<MutableList<BannerData>>> {
       return mainRepository.getBanners()
    }
    fun getGoods(category_id:Int, currentPage:Int, pageSize:Int): LiveData<ApiResponse<MutableList<Goods>>>{
        return mainRepository.getGoods(category_id,currentPage,pageSize)
    }
    //插入数据
    fun insertBanner(bannerData: BannerData){
        return mainRepository.insertBanner(bannerData)
    }
    //查询数据库
    fun getBannersFormDB():MutableList<BannerData>?{
        return mainRepository.getBannersFormDB()
    }
}